#include "warray/warray_exp.h"
#include "test.h"

#include <iostream>

#include "custom_type.h"
#include "helper.h"

typedef boost::mpl::list< float,double,std::complex<float>,std::complex<double> > test_types;

BOOST_AUTO_TEST_CASE_TEMPLATE( array_exp, T, test_types )
{
	warp::arraynd<T,1> x(warp::extents[16]);
	fill_nonzero(x);
	
	warp::arraynd<T,1> z(x.dims()); 
	warp::exp(x,z);
	BOOST_CHECK_EQUAL(x.dims(),z.dims());
	BOOST_CHECK( (array_equal(x,z,warp::detail::choose_exp<T>())) );
	
	z = warp::exp(x);
	BOOST_CHECK_EQUAL(x.dims(),z.dims());
	BOOST_CHECK( (array_equal(x,z,warp::detail::choose_exp<T>())) );
	
	z = x.copy();
	warp::exp(z,z);
	BOOST_CHECK_EQUAL(x.dims(),z.dims());
	BOOST_CHECK( (array_equal(x,z,warp::detail::choose_exp<T>())) );
}

BOOST_AUTO_TEST_CASE_TEMPLATE( array_ln, T, test_types )
{
	warp::arraynd<T,1> x(warp::extents[16]);
	fill_nonzero(x);
	
	warp::arraynd<T,1> z(x.dims()); 
	warp::ln(x,z);
	BOOST_CHECK_EQUAL(x.dims(),z.dims());
	BOOST_CHECK( (array_equal(x,z,warp::detail::choose_log<T>())) );
	
	z = warp::ln(x);
	BOOST_CHECK_EQUAL(x.dims(),z.dims());
	BOOST_CHECK( (array_equal(x,z,warp::detail::choose_log<T>())) );
	
	z = x.copy();
	warp::ln(z,z);
	BOOST_CHECK_EQUAL(x.dims(),z.dims());
	BOOST_CHECK( (array_equal(x,z,warp::detail::choose_log<T>())) );
}

BOOST_AUTO_TEST_CASE_TEMPLATE( array_log10, T, test_types )
{
	warp::arraynd<T,1> x(warp::extents[16]);
	fill_nonzero(x);
	
	warp::arraynd<T,1> z(x.dims()); 
	warp::log10(x,z);
	BOOST_CHECK_EQUAL(x.dims(),z.dims());
	BOOST_CHECK( (array_equal(x,z,warp::detail::choose_log10<T>())) );
	
	z = warp::log10(x);
	BOOST_CHECK_EQUAL(x.dims(),z.dims());
	BOOST_CHECK( (array_equal(x,z,warp::detail::choose_log10<T>())) );
	
	z = x.copy();
	warp::log10(z,z);
	BOOST_CHECK_EQUAL(x.dims(),z.dims());
	BOOST_CHECK( (array_equal(x,z,warp::detail::choose_log10<T>())) );
}
